<template>
  <div class="app-container">
    <!--搜索栏-->
    <div class="filter-container">
      <el-input v-model="listQuery.search" class="filter-item" placeholder="全局搜索" style="width:200px" />
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handlerFilter">搜索</el-button>
    </div>
    <!--表格-->
    <el-table
      v-loading="loadingTableVisible"
      :element-loading-text="loadingTableTitle"
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0.8)"
      :data="list"
      style="width: 100%;font-size:12px;"
      :row-style="{height:'30px'}"
      :cell-style="{padding:'3px'}"
      border
    >
      <el-table-column align="center" label="编号"  prop="id"  width="80">
        <template slot-scope="scope">
        <span>  {{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="用户名">
        <template slot-scope="scope">
            <span>  {{ scope.row.userName }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="产品名称">
        <template slot-scope="scope">
          <span>    {{ scope.row.projectName }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态">
        <template slot-scope="scope">
             <el-tag
            :type="scope.row.status==='running'? 'success':(scope.row.status==='stopped'?'danger':'warning')"
          >{{ parseStatus(scope.row.status) }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="开始时间" width="150px" align="center">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.startTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" width="150px" align="center">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.endTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建日期" width="150px" align="center">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.creationTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" fixed="right" width="250">
        <template slot-scope="{row}">
          <el-button type="success" size="mini" round @click="handleDetail(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
        <!--分页-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
  </div>
</template>

<script>
import waves from '@/directive/waves' // 按钮波纹
import { parseTime } from '@/utils' // 工具
import pagination from '@/components/TablePage' // 分页
import { getOperationList, getOperationInfo } from '@/api/site/operation'
import { getEnum } from '@/utils/global'
export default {
  components: { pagination },
  directives: { waves },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 20,
        search: ''
      },
      list: [],
      total: 0,
      loadingTableVisible: false,
      loadingTableTitle: '拼命加载中',
      operationStatus:null,

    }
  },
  created() {
    this.operationStatus=getEnum('saaS.Entity.Enums.OperationStatus')
    this.getOperations()
  },
  methods: {
    getOperations() {
      this.loadingTableVisible = true
      getOperationList(this.listQuery).then((response) => {
        this.list = response.data.items
        this.total = response.data.total
        this.loadingTableVisible = false
      }).catch(() => {
        this.loadingTableVisible = false
      })
    },
    handlerFilter() {

    },
    handleDetail(){

    },
    parseStatus(status){
     return this.operationStatus[status]
    }
  }
}
</script>
